﻿using HandyControl.Controls;
using HandyControl.Data;

namespace TroubleshootingofBeanBagAssistant.ViewModel
{
	/// <summary>
	/// 发送通知
	/// </summary>
	public class GrowlViewModel
	{
		private string _token;

		public GrowlViewModel()
		{

		}

		public GrowlViewModel(string token)
		{
			_token = token;
		}

		#region Window

		public GalaSoft.MvvmLight.Command.RelayCommand InfoCmd => new(() => Growl.Info(HandyControl.Properties.Langs.Lang.Pm, _token));

		public GalaSoft.MvvmLight.Command.RelayCommand SuccessCmd => new(() => Growl.Success("", _token));

		public GalaSoft.MvvmLight.Command.RelayCommand WarningCmd => new(() => Growl.Warning(new GrowlInfo
		{
			Message = HandyControl.Properties.Langs.Lang.Confirm,
			CancelStr = HandyControl.Properties.Langs.Lang.LangComment,
			ActionBeforeClose = isConfirmed =>
			{
				Growl.Info(isConfirmed.ToString());
				return true;
			},
			Token = _token
		}));

		public GalaSoft.MvvmLight.Command.RelayCommand ErrorCmd => new(() => Growl.Error(HandyControl.Properties.Langs.Lang.FormatError, _token));

		public GalaSoft.MvvmLight.Command.RelayCommand AskCmd => new(() => Growl.Ask(HandyControl.Properties.Langs.Lang.All, isConfirmed =>
		{
			Growl.Info(isConfirmed.ToString());
			return true;
		}, _token));



		public GalaSoft.MvvmLight.Command.RelayCommand FatalCmd => new(() => Growl.Fatal(new GrowlInfo
		{
			Message = HandyControl.Properties.Langs.Lang.NoData,
			ShowDateTime = false,
			Token = _token
		}));

		public GalaSoft.MvvmLight.Command.RelayCommand ClearCmd => new(() => Growl.Clear(_token));

		#endregion

		#region Desktop

		public GalaSoft.MvvmLight.Command.RelayCommand InfoGlobalCmd => new(() => Growl.InfoGlobal(HandyControl.Properties.Langs.Lang.All));

		public GalaSoft.MvvmLight.Command.RelayCommand SuccessGlobalCmd => new(() => Growl.SuccessGlobal("复制成功"));

		public GalaSoft.MvvmLight.Command.RelayCommand WarningGlobalCmd => new(() => Growl.WarningGlobal(new GrowlInfo
		{
			Message = HandyControl.Properties.Langs.Lang.NoData,
			CancelStr = HandyControl.Properties.Langs.Lang.FormatError,
			ActionBeforeClose = isConfirmed =>
			{
				Growl.InfoGlobal(isConfirmed.ToString());
				return true;
			}
		}));

		public GalaSoft.MvvmLight.Command.RelayCommand ErrorGlobalCmd => new(() => Growl.ErrorGlobal(HandyControl.Properties.Langs.Lang.FormatError));

		public GalaSoft.MvvmLight.Command.RelayCommand AskGlobalCmd => new(() => Growl.AskGlobal(HandyControl.Properties.Langs.Lang.FormatError, isConfirmed =>
		{
			Growl.InfoGlobal(isConfirmed.ToString());
			return true;
		}));

		public GalaSoft.MvvmLight.Command.RelayCommand FatalGlobalCmd => new(() => Growl.FatalGlobal(new GrowlInfo
		{
			Message = HandyControl.Properties.Langs.Lang.Miscellaneous,
			ShowDateTime = false
		}));

		public GalaSoft.MvvmLight.Command.RelayCommand ClearGlobalCmd => new(Growl.ClearGlobal);

		#endregion

		//public GalaSoft.MvvmLight.Command.RelayCommand NewWindowCmd => new(() => new GrowlDemoWindow
		//{
		//    Owner = Application.Current.MainWindow
		//}.Show());
	}
}
